#include <stdio.h>

struct ListNode {
    int val;
    struct ListNode *next;
};

//递归
struct ListNode* ReverseLists(struct ListNode* head) {
    if (head == NULL || head->next == NULL) {
        return head;
    }
    struct ListNode *newHead = ReverseLists(head->next);
    head->next->next = head;
    head->next = NULL;
    return newHead;
}

//循环
struct ListNode* ReverseList(struct ListNode* head) {
    struct ListNode* prev = NULL;
    struct ListNode* curr = head;
    while (curr) {
        struct ListNode* next = curr->next;
        curr->next = prev;
        prev = curr;
        curr = next;
    }
    return prev;
}

struct ListNode* reverseList(struct ListNode* head){
    if (head == NULL) {
        return head;
    }
    struct ListNode *prev = NULL;
    struct ListNode *cur = head;
    struct ListNode *next = head->next;
    while (next != NULL) {
        cur->next = prev;
        prev = cur;
        cur = next;
        next = next->next;
    }
    cur->next = prev;
    return cur;
}

int main() {

    return 0;
}